package com.ruoyi.patrol.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.patrol.domain.PtDailyFormType;
import com.ruoyi.patrol.service.IPtDailyFormTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 常用单类型及模版位置Controller
 * 
 * @author lkm
 * @date 2023-11-17
 */
@RestController
@RequestMapping("/patrol/dailyformtype")
public class PtDailyFormTypeController extends BaseController
{
    @Autowired
    private IPtDailyFormTypeService ptDailyFormTypeService;

    /**
     * 查询常用单类型及模版位置列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtDailyFormType ptDailyFormType)
    {
        startPage();
        List<PtDailyFormType> list = ptDailyFormTypeService.selectPtDailyFormTypeList(ptDailyFormType);
        return getDataTable(list);
    }

    /**
     * 导出常用单类型及模版位置列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:export')")
    @Log(title = "常用单类型及模版位置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PtDailyFormType ptDailyFormType)
    {
        List<PtDailyFormType> list = ptDailyFormTypeService.selectPtDailyFormTypeList(ptDailyFormType);
        ExcelUtil<PtDailyFormType> util = new ExcelUtil<PtDailyFormType>(PtDailyFormType.class);
        return util.exportExcel(list, "type");
    }

    /**
     * 获取常用单类型及模版位置详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ptDailyFormTypeService.selectPtDailyFormTypeById(id));
    }

    /**
     * 新增常用单类型及模版位置
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:add')")
    @Log(title = "常用单类型及模版位置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtDailyFormType ptDailyFormType)
    {
        return toAjax(ptDailyFormTypeService.insertPtDailyFormType(ptDailyFormType));
    }

    /**
     * 修改常用单类型及模版位置
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:edit')")
    @Log(title = "常用单类型及模版位置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtDailyFormType ptDailyFormType)
    {
        return toAjax(ptDailyFormTypeService.updatePtDailyFormType(ptDailyFormType));
    }

    /**
     * 删除常用单类型及模版位置
     */
    @PreAuthorize("@ss.hasPermi('patrol:type:remove')")
    @Log(title = "常用单类型及模版位置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ptDailyFormTypeService.deletePtDailyFormTypeByIds(ids));
    }
}
